﻿using Design.Common.Utils;

namespace SingletonPattern
{
    internal sealed class SystemLazySingleton
    {
        private static Lazy<SystemLazySingleton> _instance = new(() => new SystemLazySingleton());
        private const string _name = "系统Lazy模式";

        private SystemLazySingleton()
        {
            ConsoleExpansion.WriteLine($"{_name} 创建实例:{Guid.NewGuid()}");
        }

        public static SystemLazySingleton Instance
        {
            get
            {
                ConsoleExpansion.WriteLine($"{_name} 获取实例 is null {_instance.Value == null}");

                return _instance.Value;
            }
        }
    }
}